//
//  TabBarViewController.m
//  OurMenu
//
//  Created by lanou3g on 15/10/12.
//  Copyright © 2015年 尹坤. All rights reserved.
//

#import "TabBarViewController.h"

@interface TabBarViewController ()

@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if (![defaults boolForKey:@"firstStart"]) {
        [defaults setBool:YES forKey:@"firstStart"];
        self.introView = [[ABCIntroView alloc] initWithFrame:self.view.frame];
        self.introView.delegate = self;
        self.introView.backgroundColor = [UIColor grayColor];
        [self.view addSubview:self.introView];
        [self creatController];
    }else{
        [self creatController];
    }
    
    // Do any additional setup after loading the view.
}

-(void)onDoneButtonPressed{
    
    [UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.introView.alpha = 0;
    } completion:^(BOOL finished) {
        [self.introView removeFromSuperview];
    }];
}


-(void)creatController
{
    #pragma mark - 首页
    HomeViewController *home = [[HomeViewController alloc] init];
    UINavigationController *homeNav = [[UINavigationController alloc] initWithRootViewController:home];
    UIImage *imageHomeS = [UIImage imageNamed:@"Tabbar_Recipes_Selected@2x"];
    
    imageHomeS = [imageHomeS imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIImage *imageHomeN = [UIImage imageNamed:@"Tabbar_Recipes@2x"];
    
    imageHomeN = [imageHomeN imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    homeNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:imageHomeN selectedImage:imageHomeS];
    
    #pragma mark - 搜索
    SearchViewController *search = [[SearchViewController alloc] init];
    UINavigationController *searchNav = [[UINavigationController alloc] initWithRootViewController:search];
    UIImage *imageSearchS = [UIImage imageNamed:@"Icon_Plan_Search_Active@2x"];
    UIImage *imageSearchN = [UIImage imageNamed:@"Icon_Plan_Search@2x"];
    
    imageSearchS = [imageSearchS imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    imageSearchN = [imageSearchN imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    searchNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"搜索" image:imageSearchN selectedImage:imageSearchS];
    
    #pragma mark - 我的
    MyViewController *my = [[MyViewController alloc] init];
    UINavigationController *myNav = [[UINavigationController alloc] initWithRootViewController:my];
    UIImage *myS = [UIImage imageNamed:@"Tabbar_Mine_Selected@2x"];
    UIImage *myN = [UIImage imageNamed:@"Tabbar_Mine@2x"];
    myS = [myS imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    myN = [myN imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    myNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:myN selectedImage:myS];
    
    #pragma mark - 设置
    SetViewController *set = [[SetViewController alloc] init];
    UINavigationController *setNav = [[UINavigationController alloc] initWithRootViewController:set];
    UIImage *imageSetS = [UIImage imageNamed:@"Tabbar_Recommend_Selected@2x"];
    UIImage *imageSetN = [UIImage imageNamed:@"Tabbar_Recommend@2x"];
    imageSetS = [imageSetS imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    imageSetN = [imageSetN imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    setNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"设置" image:imageSetN selectedImage:imageSetS];
    
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:200/255.0 green:71/255.0 blue:50/255.0 alpha:0.85]];
    [[UINavigationBar appearance] setTranslucent:NO];
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"7197a08e13a4f608a369cece49190ca8"] forBarMetrics:UIBarMetricsDefault];
    #pragma mark - 将标签添加到tabBar上
    self.viewControllers = [NSArray arrayWithObjects:homeNav,searchNav,myNav,setNav, nil];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
